package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.PrefrenceAreaProductRelation;
import com.itheima.mapper.PrefrenceAreaProductRelationMapper;
import com.itheima.service.IPrefrenceAreaProductRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 优选专区和产品关系表 服务实现类
 * </p>
 *
 * @author fukeke
 * @since 2022-11-11
 */
@DubboService
public class PrefrenceAreaProductRelationServiceImpl extends ServiceImpl<PrefrenceAreaProductRelationMapper, PrefrenceAreaProductRelation> implements IPrefrenceAreaProductRelationService {
    @Autowired
    PrefrenceAreaProductRelationMapper prefrenceAreaProductRelationMapper;

    @Override
    public List<PrefrenceAreaProductRelation> selectByProductId(Long productId) {
        LambdaQueryWrapper<PrefrenceAreaProductRelation> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PrefrenceAreaProductRelation::getProductId,productId);
        return prefrenceAreaProductRelationMapper.selectList(queryWrapper);
    }

    @Override
    public void createCmsPrefrenceAreaProductRelation(PrefrenceAreaProductRelation cmsPrefrenceAreaProductRelation) {
        prefrenceAreaProductRelationMapper.insert(cmsPrefrenceAreaProductRelation);
    }
}
